//
//  @ Project : Galaxy Star Trading System
//  @ File Name : MsgBus.h
//  @ Date : 2014/9/5
//  @ Author :
//
//


#if !defined(_CMSGBUS_H_H)
#define _CMSGBUS_H_H

namespace GSTrader
{
	namespace TradeStrategy
	{
		class CMsgBus
		{
		public:
			CMsgBus(CFramework* pFramework, int nMode);
			virtual ~CMsgBus();

			CMsg* Pop();
			void Clear();

			void AddQueue(CMsgQueue* pQueue);
			void RemoveQueue(CMsgQueue* pQueue);

			void Stop();
			CMsgQueue* GetServiceQueue();
		public:
			atomic<bool> m_bRunning;

		private:
			int m_nMode;	//

			CMsgPipe*		m_pTradePipe;
			CMsgPipe*		m_pDataPipe;
			CMsgPipe*		m_pServicePipe;

			CFramework*		m_pFramework;
			CMsg*			m_pMsg;
			list<CMsgQueue*> m_lExternalQueue;

			CTimerQueue*	m_pLocalTimerQueue;
			CTimerQueue*	m_pExchangeTimerQueue;

			friend class CFramework;
			friend class CTradeClient;
			friend class CMarketDataClient;
			friend class CSimuMarketDataClient;
			friend class CScenario;
		};
	}
}


#endif // _CMSGBUS_H_H